package modeller.databasedesignmodel.servicedemand.transaction.proceduralstatement;

import modeller.databasedesignmodel.relation.Relation;
import modeller.databasedesignmodel.servicedemand.IServiceDemand;

/**
 * Created by:  Jason Ye
 * Date:        24/03/2012
 * Time:        10:51
 */
public class LoopServiceDemand implements ProceduralStatementServiceDemand {

    private IServiceDemand contentsDemand;
    private double numIterations;

    public LoopServiceDemand(IServiceDemand b,int it) {
        contentsDemand = b;
        numIterations = it;
    }

    @Override
    public String myToString() {
        
        return "Loop - with "+
                numIterations +
                " iterations:\n\tContents' service demand:\n"
                + contentsDemand.myToString();
    }

    @Override
    public double getServiceDemandForRelation(Relation relation) {
        return contentsDemand.getServiceDemandForRelation(relation) * numIterations;
    }

    public IServiceDemand getContentsDemand() {
        return contentsDemand;
    }

    public void setContentsDemand(IServiceDemand contentsDemand) {
        this.contentsDemand = contentsDemand;
    }

    public double getNumIterations() {
        return numIterations;
    }

    public void setNumIterations(double numIterations) {
        this.numIterations = numIterations;
    }
}
